<!--header-->
<!--# include virtual="/ceca_two/common/html/header.html"-->
<link rel="stylesheet" href="/ceca_two/css/bazaarInformation.css" />
<div class="banner">
	<div class="h">
		<div class="navBox">
			<div class="title" onclick="window.location.href='screeningResults.html'">全部分类<img src="/ceca_two/img/down_arrow.png" alt="" /></div>
			<div class="cont" id="classiftBox"></div>
		</div>
		<div class="content">
			<div class="bazaarPage">
				<p class="PageP">全国建筑材料设备<br>市场价格信息查询平台</p>
				<div class="bazaarPageInp">
					<input type="text" id="search"  name="search" class="PageInp" placeholder="请输入材料名称"/>
					<button class="PageBtn" style="cursor:pointer">搜索</button>
				</div>
			</div>
			<div class="bazaarControl">
				<a href="javascript:void(0)"><img src="/ceca_two/img/up_arrow.png"/></a>
				<a href="javascript:void(0)" class="bazaarControlBottom"><img src="/ceca_two/img/down_arrow.png"/ ></a>
			</div>
		</div>
	</div>
</div>
<script type="text/html" id="classiftItem">
	{{#  layui.each(d, function(index, item){ }}
		<div>
			<ul data-categoryName="{{item.categoryName}}">
				{{item.categoryName}}
			</ul>
			{{# if(item.sonlassift.length>0){ }}
				<dl>
					{{#  layui.each(item.sonlassift, function(a,b){ }}
							<dt data-categoryName="{{b.categoryName}}">{{b.categoryName}}</dt>
							
								{{# if(b.sonlassift.length > 0){ }}
								
									{{#  layui.each(b.sonlassift, function(c,d){ }}
									
										<dd data-categoryName="{{d.categoryName}}" title="{{d.categoryName}}">{{d.categoryName}}</dd>
										
									{{# }); }}
									
								{{# } }}
								
					{{# }); }}
				</dl>
			{{# } }}
		</div>
	{{# }); }}
</script>
<!--底部-->
<!--# include virtual="/ceca_two/common/html/footer.html"-->
<script>
layui.use(['Router','Zarea','Zutil',], function() {
	var Router = layui.Router;
	var Zarea = layui.Zarea;
	var Zutil = layui.Zutil;
	var laytpl= layui.laytpl;
	var Url = Router.link.materialPrice.getMarketCategory;
	$.post(Url,{},function(result){
		var  data = result.data;
		sessionStorage.setItem("marketCategory",data.toString());
		var finalData=[];
		var datalength;
		var temp;

		for(var i=0;i<data.length;i++){
			if(data[i].categoryParentId=="0"){
				temp=data[i];
				temp["sonlassift"]=[];
				finalData.push(temp);
			}
		}
		for(var i=0;i<finalData.length;i++){
			for(var j=0;j<data.length;j++){
				if(data[j].categoryParentId==finalData[i].categoryId){
					temp=data[j];
					temp["sonlassift"]=[];
					finalData[i]["sonlassift"].push(data[j]);
				}
			}
		}

		
		for (i = 0 ; i < finalData.length ; i++) {
			for (j = 0 ; j < finalData[i].sonlassift.length ; j++) {
				for (k = 0 ; k < data.length ; k++) {
					if(data[k].categoryParentId == finalData[i].sonlassift[j].categoryId){

						finalData[i].sonlassift[j]["sonlassift"].push(data[k]);
					}
				}
			}
		}
		
		console.log(finalData)

		laytpl(classiftItem.innerHTML).render(finalData, function(html){
			classiftBox.innerHTML = html;
		});
		
		
		$("#classiftBox div").on("mouseover",function (){
			$(this).addClass("active").find("dl").show();
		}).on("mouseout",function (){
			$(this).removeClass("active").find("dl").hide();
		}).find("dd").click(function(){
			var categoryName = window.btoa(Zutil.encodeURI($(this).attr("data-categoryName")));
			var areaCode =   JSON.parse(sessionStorage.getItem("nowCity")) ==null? "":JSON.parse(sessionStorage.getItem("nowCity")).adcode;
			window.location.href='/ceca_two/modules/market/screeningResults.html?areaCode='+areaCode+'&categoryName='+categoryName;
		});
		
	});
	$('.bazaarControl').on("");
	$(".PageBtn").click(function(){
		var areaCode =   JSON.parse(sessionStorage.getItem("nowCity")) ==null? "":JSON.parse(sessionStorage.getItem("nowCity")).adcode;
		var search = $("input[name='search']").val() || "";
		if(!search){
			$("#search").addClass("warn_anim");
			setTimeout(function(){
				$("#search").removeClass("warn_anim");
			},1200);
			return;
		}
		search = window.btoa(Zutil.encodeURI(search));
		window.location.href='/ceca_two/modules/market/screeningResults.html?areaCode='+areaCode+'&search='+search
	});
	$("#search").keydown(function(event){
		var e = event || window.event || arguments.callee.caller.arguments[0];
		if(e && e.keyCode==13){ // enter 键
			var areaCode =   JSON.parse(sessionStorage.getItem("nowCity")) ==null? "":JSON.parse(sessionStorage.getItem("nowCity")).adcode;
			var search = $("input[name='search']").val() || "";
			if(!search){
				$("#search").addClass("warn_anim");
				setTimeout(function(){
					$("#search").removeClass("warn_anim");
				},1200);
				return;
			}
			search = window.btoa(Zutil.encodeURI(search));
			window.location.href='/ceca_two/modules/market/screeningResults.html?areaCode='+areaCode+'&search='+search;
        }
	});
});
</script>
</body>
</html>